package design_pattern.factory.simple_factory;

/**
 * 生产颜色对象的工厂
 * @author 15594
 */
public class ColourFactory {

    /**
     * @return 返回抽象的产品
     * @param name 根据输入的颜色类型名字返回向上转型的颜色对象
     * */
    public static Colour getColour(String name){
        switch (name){
            case "red":
                return new Red();
            case "yellow":
                return new Yellow();
            default:
                throw new RuntimeException("没有这个颜色");
        }
    }

}
